package cays.student.controller;

import cays.student.service.StudentService;
import cays.student.vo.ResultVO;
import cays.student.vo.Student;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 学生信息Restful接口
 *
 * @author Chai yansheng
 * @create 2019/8/29
 **/
@RestController
@RequestMapping("/student")
public class StudentController {
    @Autowired
    private StudentService studentService;

    @GetMapping("/get/{sno}")
    ResultVO getStudentBySno(@PathVariable("sno") String sno) {
        return new ResultVO("0", studentService.getStudentBySno(sno));
    }

    @GetMapping("/list")
    ResultVO getAllStudent() {
        return new ResultVO("0", studentService.getAllStudent());
    }

    @PostMapping("/update")
    ResultVO updateStudentBySno(@RequestBody Student student) {
        return new ResultVO("0", studentService.updateStudentBySno(student));
    }

    @PostMapping("/insert")
    ResultVO insertStudent(@RequestBody Student student) {
        return new ResultVO("0", studentService.insertStudent(student));
    }

    @GetMapping("/delete/{sno}")
    ResultVO deleteStudentBySno(@PathVariable("sno") String sno) {
        return new ResultVO("0", studentService.deleteStudentBySno(sno));
    }

}
